import java.net.*;
import java.io.*;

public class ServerMock {
    public static void main(String[] args)    {
        int port = 25567;
        try {
            ServerSocket ss = new ServerSocket(port);
            System.out.println("Waiting for a client...");

            Socket socket = ss.accept();
            System.out.println("Got a client :) ... Finally, someone saw me through all the cover!");
            System.out.println();

            InputStream sin = socket.getInputStream();
            OutputStream sout = socket.getOutputStream();

            DataInputStream in = new DataInputStream(sin);
            DataOutputStream out = new DataOutputStream(sout);

            int data;
            while(true) {
                data = in.readInt();
                System.out.println(data);
                out.writeInt(data);
                out.flush();
                System.out.println("Waiting for the next int...");
            }
        } catch(Exception x) { x.printStackTrace(); }
    }
}